package com.shushan.manager.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.shushan.base.BaseFragment;
import com.shushan.manager.SoftWareMgFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: SoftMgPagerAdapter
 * @Desciption: 软件管理适配器
 * @author: yichaohua
 * @date: 2018-07-17
 */
public class SoftMgPagerAdapter extends FragmentPagerAdapter {

    private final int PAGE_COUNT = 3;
    private String[] tableTitle = new String[] {"全部软件", "黑名单", "白名单"};
    private Context mContext;

    private List<SoftWareMgFragment> mFragmentTab;
    public static SoftWareMgFragment allSoftFragment;
    public static SoftWareMgFragment blackSoftFragment;
    public static SoftWareMgFragment whiteSoftFragment;

    public SoftMgPagerAdapter(FragmentManager fm,Context mContext) {
        super(fm);
        this.mContext = mContext;
        initFragmentTab();
    }


    @Override
    public Fragment getItem(int position) {
        return mFragmentTab.get(position);
    }

    @Override
    public int getCount() {
        return PAGE_COUNT;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tableTitle[position];
    }

    private void initFragmentTab() {
        allSoftFragment = new SoftWareMgFragment(1);
        blackSoftFragment = new SoftWareMgFragment(2);
        whiteSoftFragment = new SoftWareMgFragment(3);

        mFragmentTab = new ArrayList<SoftWareMgFragment>();
        mFragmentTab.add(allSoftFragment);
        mFragmentTab.add(blackSoftFragment);
        mFragmentTab.add(whiteSoftFragment);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
//        super.destroyItem(container, position, object);
    }
}
